
<?php 	
	// session_start();
	include 'init.php';
	$jbanner = get_config('banner');
	$banner = json_decode($jbanner,true);
	

	//查找数据库
	if (isset($_GET['art_id'])&&$_GET['art_id']>0) {
		// echo $_GET['art_id'];
		//找出浏览量
		$sql="SELECT viewd FROM article WHERE id={$_GET['art_id']}";
		$view=$mysql->getOne($sql)+1;
		//更新浏览量
		$sql="UPDATE article SET viewd='{$view}'  WHERE  id={$_GET['art_id']}";
		$mysql->query($sql);
		//找出文章所有信息
		$sql = "SELECT * FROM article LEFT JOIN article_to_category on article.id=article_to_category.article_id LEFT JOIN category on article_to_category.category_id=category.id WHERE article.id='{$_GET['art_id']}' ";
		$resultRow=$mysql->getRow($sql);

		$sqlcate = "SELECT name FROM article_to_category  LEFT JOIN category on article_to_category.category_id=category.id WHERE article_to_category.article_id='{$_GET['art_id']}' ";
		$cates = $mysql->getAll($sqlcate);
		
		// print_r($cates);
		$sql="SELECT * from message where article_id=".$_GET['art_id'];
		$r=$mysql->getAll($sql);
	}
	
	//显示留言列表
	
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title><?php echo get_config('title');?></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<!-- Custom Theme files -->
<link href="public/css/bootstrap.css" type="text/css" rel="stylesheet" media="all">
<link href="public/css/style.css" type="text/css" rel="stylesheet" media="all">  
<!-- //Custom Theme files -->
<!-- font-awesome icons -->
<link href="public/css/font-awesome.css" rel="stylesheet"> 
<!-- //font-awesome icons -->
<!-- js -->
<script src="public/js/jquery-2.2.3.min.js"></script> 
<!-- //js -->
<link rel="stylesheet" type="text/css" href="public/bootsrap/css/bootstrap.min.css">
<!-- start-smooth-scrolling -->
<script type="text/javascript" src="public/js/move-top.js"></script>
<script type="text/javascript" src="public/js/easing.js"></script>	
<script type="text/javascript">
		jQuery(document).ready(function($) {
			$(".scroll").click(function(event){		
				event.preventDefault();
				$('html,body').animate({scrollTop:$(this.hash).offset().top},1000);
			});
		});
</script>
<!-- //end-smooth-scrolling -->
</head>
<body>
	<!-- banner start here -->
	<div class="agileinfo-main about-top">
		<div class="slider">
			<script src="public/js/responsiveslides.min.js"></script>
			<script>
				// You can also use "$(window).load(function() {"
				$(function () {
				  // Slideshow 1
				  $("#slider1").responsiveSlides({
					 auto: true,
					 nav: true,
					 speed: 500,
					 namespace: "callbacks",
				  });
				});
			</script>
			<ul class="rslides" id="slider1" style="height: 300px;">
				<li>
					<div class="banner" style="background: url('public/upload/<?php echo $banner[0]['banner'];?>')no-repeat center;">
						<h3>把醉了的明天寄托在潘多拉的琴弦、浮沉余生虚伪地歌咏天上人间。 </h3>
					</div>
				</li>
				<li>
					<div class="banner banner2" style="background: url('public/upload/<?php echo $banner[1]['banner'];?>')no-repeat center;">
						<h3>话说天下大势，分久必和，合久必分。 </h3>
					</div>
				</li>
				<li>
					<div class="banner banner3" style="background: url('public/upload/<?php echo $banner[2]['banner'];?>')no-repeat center 0px;">
						<h3>相思只在梦魂中。今宵月，偏照小楼东。 </h3>
					</div>
				</li>
			</ul>
		</div>  
		<div class="agileinfo-header">
			<div class="container">
				<div class="agile-logo">
					<h1><a href="index.html"><i class="fa bounce bounceIn animated" aria-hidden="true"><img src="public/upload/<?php echo get_config('sitelogo');?>" style="width: 60px;height: 60px;"><br></i> <a style="font-size: 30px;font-weight: bolder;color: #fff;">风散了墨香</a>
					<!-- Rock -->
					</a></h1>
				</div>
				<div class="agileits-w3layouts-icons">
					<div class="social-icon">
						<!-- <a href="#" class="social-button qq" title=""QQ登录><i class="fa fa-qq">QQ</i></a>
						<a href="#" class="social-button weibo"><i class="fa fa-weibo" ></i></a> 
						<a href="#" class="social-button weixin"><i class="fa fa-comments" aria-hidden="true"></i></a> -->
						<!-- <a href="#" class="social-button register"><i class="fa ">注册</i></a> -->
						<a href="admin/login.php" class="social-button sign-in" title="管理员登录" alt="管理员登录"><i class="fa fa-user fa-fw"></i></a>
					</div> 
				</div>
				<div class="clearfix"> </div>
			</div>	    
		</div>
		<!-- navigation start here -->
		<div class="top-nav">
			<span class="menu">Menu</span>	
			<ul class="w3l">
				<li><a href="index.php"><i aria-hidden="true" class="glyphicon glyphicon-home"></i><span>主页</span></a></li>
				
				<li><a href="blog.php"><i class="glyphicon glyphicon-list-alt"></i><span>博文排列</span></a></li>
				<li><a href="codes.php"><i class="glyphicon glyphicon-picture"></i><span>博图排列</span></a></li>
				<li><a href="about.php"><i class="glyphicon glyphicon-user"></i><span>关于</span></a></li>
				<li><a href="contact.php"><i class="glyphicon glyphicon-envelope"></i><span>联系</span></a></li>
			</ul>
			<!-- script-for-menu -->
			<script>
			   $( "span.menu" ).click(function() {
				 $( "ul.w3l" ).slideToggle( 300, function() {
				 // Animation complete.
				  });
				 });
			</script>
			<!-- //script-for-menu -->
		</div>	
	</div>
	<!-- //navigation end here --> 
	<!-- single -->
	<div class="single">
		<div class="container">
			<div class="wthree_single_grid">
				<h2><?php if (isset($_GET['art_id'])&&$_GET['art_id']>0) { echo $resultRow['title'];} ?></h2>
				<!-- <ul>
					<a href="#" id="smalltext">
						<li><a class="btn btn-success" style="font-size: 15PX;font-weight: bolder;">小</a></li>
					</a>
					<a href="" id="middletext">
						<li><a  class="btn btn-success" style="font-size: 15PX;font-weight: bolder;">中</a></li>
					</a>
					<a href="" id="bigtext">
						<li><a  class="btn btn-success" style="font-size: 15PX;font-weight: bolder;">大</a></li>
					</a>
					
				</ul> -->
				<ul>
					<li><span class="fa fa-user" aria-hidden="true"></span><a href="#"><?php echo $resultRow['author']; ?></a></li>
					<li><span class="fa fa-eye" aria-hidden="true"></span><a href="#"><?php echo $resultRow['viewd']; ?></a></li>
					<li><span class="fa fa-list" aria-hidden="true"></span><a href="#"><?php foreach ($cates as $key => $value) {
						echo $value['name']."  ";
					} ?></a></li>
					<li><span class="fa fa-calendar" aria-hidden="true"></span><?php echo date('Y年m月d日 H:m',$resultRow['add_time']);  ?></li>
					<li><a href="#message_bord" class="btn btn-success">发表留言</a></li>
					<li><a href="#messag_list" class="btn btn-success">查看留言</a></li>
					
				</ul>
			</div>
			<div class="agile_single_banner">
				<div style="display:inline-block;width:500px;height:auto;margin-bottom: 15px; ">
					<img src="public/upload/<?php echo $resultRow['img']; ?>" alt="" class="img-responsive" />
				</div>

			</div>
			<div class="wthree_single_grid1" style="height: auto;">

					<div style="width: 100%;height: auto;">
						<blockquote style="word-break: break-all;width: 80%;" id="content_text">
							<?php echo $resultRow['content']; ?>
						</blockquote>
					</div>
			</div> 
			<hr style="height: 3px;color: gray;">
			<div class="bshare-custom icon-medium" style="float: right;margin-right: 20px;"><a title="分享到QQ好友" class="bshare-qqim"></a><a title="分享到微信" class="bshare-weixin"></a><a title="分享到新浪微博" class="bshare-sinaminiblog"></a><a title="分享到QQ空间" class="bshare-qzone"></a><a title="分享到腾讯微博" class="bshare-qqmb"></a><a title="分享到网易微博" class="bshare-neteasemb"></a><a title="更多平台" class="bshare-more bshare-more-icon more-style-addthis"></a><span class="BSHARE_COUNT bshare-share-count">0</span></div><script type="text/javascript" charset="utf-8" src="http://static.bshare.cn/b/buttonLite.js#style=-1&amp;uuid=&amp;pophcol=1&amp;lang=zh"></script><script type="text/javascript" charset="utf-8" src="http://static.bshare.cn/b/bshareC0.js"></script>
			<div>&nbsp;</div>
			<div>&nbsp;</div>
			
			<script type="text/javascript">
			    $(function(){
			    	$('#smalltext').on('click',function(){
			    		$('#content_text').style.font-size='8px';
			    	});
			    });
			 </script>

			
			<!-- 留言列表 -->
			<div class="write-reply" id="messag_list">
				<input type="submit" value="留言列表(点击显示或隐藏)" id="messagebut" style="height: 60px;font-size: 20px;">
				<div id="listmsg">
					<?php if (empty($r)) {?>
						<div class="bordmsg">
							<blockquote>
								<h1 class="w3ls-title" style="text-align: center;color: #444;">第一个沙发是你的了！\(0^◇^0)/</h1>
							</blockquote>
							
							<hr>
							<div style="text-align: right;font-size: 10px;color: #666;">
								<div style="margin-right: 20px;">&nbsp;</div>
								<div style="margin-right: 20px;">&nbsp;</div>
							</div>	
						</div>
					<?php }else{ ?>
						<?php foreach ($r as $key => $value) { ?>
							<div class="bordmsg">
								<blockquote>
									<h5 class="w3ls-title"><?php echo $value['message_content']; ?></h5>
								</blockquote>
								
								<hr>
								<!-- <div class="review">
									<button class="review_btn btn btn-info" style="float: right;height: 40px;"><i class="fa fa-lg fa-comment-o" aria-hidden="true"></i></button>
								</div> -->
								<!-- <br><br> -->
								<div style="text-align: right;font-size: 10px;color: #666;">
									<div style="margin-right: 20px;"><?php echo '游客昵称：'.$value['nickname']; ?></div>
									<div style="margin-right: 20px;"><?php echo date("Y年m月d日 H:i",$value['message_time']); ?></div>
								</div>
								
							</div>
						<?php } ?>
					<?php } ?>
				</div>
				
			</div>
			<div>&nbsp;</div>
			<div class="write-reply" id="message_bord">
				<h4 class="w3ls-title">留言板</h4>
				<form action="messageadd.php" method="post" id="message"> 
					<input type="hidden" name="article_id" value="<?php if (isset($_GET['art_id'])) {
						echo $_GET['art_id'];
					} ?>">
					<input type="text" name="nickname" placeholder="昵称"  required="">
					<input type="text" name="email" placeholder="邮箱" required=""> 
					<textarea name="message_content" placeholder="写下留言" required="" style="margin-bottom: 5px;"></textarea>
					<input type="text" name="cap" id="captachword" placeholder="输入验证码……" required="" style="width: 500px;">&nbsp;&nbsp;<a id="captachimg"><img src="captach.php" ></a>
					<a id="captachinfo"></a>
					<br>
					<button class="btn btn-lg btn-success" style="width: 100%;">保存</button>
					<!-- <input type="submit" value="保存" > -->
				</form>
			</div>
		</div>
	</div>
	<!-- 提示弹窗 -->
	<div class="modal fade bs-example-modal-sm" id="myModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
	    <div class="modal-dialog modal-sm" role="document">
	      <div class="modal-content">

	        <div class="modal-header">
	          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
	          <h4 class="modal-title" id="mySmallModalLabel">提示您的操作：</h4>
	        </div>
	        <div class="modal-body">
	          ...
	        </div>
	      </div>
	    </div>
	</div>

	<!-- 留言板回复 -->
	<!-- <script type="text/javascript">
		$('.review_btn').on('click',  function() {
			$('.review').html('<form action="messageadd.php" method="post"><input type="hidden" name="art_id" value="<?php if (isset($_GET['art_id'])) { echo $_GET['art_id'];} ?>"/><input type="text" name="review_word" style="width: 85%;"><button class="review_btn btn btn-success" style="float: right;height:40px;">提交评论</button><form>');
		});
	</script> -->
	<!-- 刷新验证码 -->
	<script type="text/javascript">
		$('#captachimg').on('click',function(){
			$('#captachimg').html('<img src="captach.php" id="captachimg" >');
		});
	</script>

	<!-- 留言列表 -->
	<script type="text/javascript">
		$("#messagebut").on('click',function(){
			$('#listmsg').slideToggle("slow");
		});
	</script>
	<!-- 留言板提交 -->
	<script type="text/javascript">
		$('#message').on('submit',function(){
			$.ajax({
				type:'post', 
				url:$('#message').attr('action'),
				data:$('#message').serialize(),
				dataType:'json',
				success:function(data){
					if(data.code=='400'){
						$('#myModal .modal-body').html(data.msg);
						$('#myModal').modal({'show':true});
					}else{
						$('#myModal .modal-body').html(data.msg);
						$('#myModal').modal({'show':true});
						window.location="single.php?art_id="+<?php echo $_GET['art_id']; ?>;
					}
				}
			});	
			return false;
		});
	</script>
	
	<!-- //single -->  
	<?php include 'footer.php'; ?>
	<!-- smooth-scrolling-of-move-up -->
	<script type="text/javascript">

		$(document).ready(function() {
			/*
			var defaults = {
				containerID: 'toTop', // fading element id
				containerHoverID: 'toTopHover', // fading element hover id
				scrollSpeed: 1200,
				easingType: 'linear' 
			};
			*/
			
			$().UItoTop({ easingType: 'easeOutQuart' });
			
		});
	</script> 
	<!-- //smooth-scrolling-of-move-up -->
	<!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="public/js/bootstrap.js"></script>
</body>
</html>